package dirindex;

import java.util.*;

import gate.*;

public class SortedAnnotationList extends Vector {

	public SortedAnnotationList() 
	{
	       super();
	}
	
	 public boolean addSortedExclusive(Annotation annot) {
	       // overlapping check
	       for (int i=0; i < size(); ++i) {	    	   
	         if(annot.overlaps((Annotation) get(i))) {
	           return false;
	         } // if
	       } // for
	 
	       long annotStart = annot.getStartNode().getOffset().longValue();
	       // insert
	       for (int i=0; i < size(); ++i) {
	         if(annotStart < ((Annotation) get(i)).getStartNode().getOffset().longValue()) {
	           insertElementAt(annot, i);
	           return true;
	         } // if
	       } // for
	 
	       //int size = size();
	       insertElementAt(annot, size());
	       return true;
	     }
}
